<?php

namespace App\Models;


use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;

class FormIds extends Model
{
    protected $table = 'formids';
    protected $fillable = [
        'formid', 'userid', 'openid', 'created_at', 'expires_at',
    ];
    public $timestamps = false;//关闭自动维护
    public $dates = ['created_at','expires_at'];





    protected function add($formid){
        $form = [
            'created_at' => Carbon::now(),
            'expires_at' => Carbon::now()->addHours(160),
            'formid'     => $formid,
            'openid'     => auth()->guard('api')->user()->openid,
            'userid'     => auth()->guard('api')->id(),
        ];
        $this->create($form);
    }
}
